import GameConfig from "./GameConfig";


cc.Class({
    extends: cc.Component,

    properties: {
        posX: 0,
        initY: 0,
        loop: true, // 是否循环显示
    },

    start () {
        this.posY = this.initY;
    },

    _wallMove(posX, posY) {
        this.node.setPosition(cc.v2(posX, posY));
    },

    update (dt) {
        if (GameConfig.GAME_START) {
            this.posY -= GameConfig.PROPS_PLAYER_MOVE_SPEED;
            if (this.loop) {
                if (this.posY <= -240) {
                    this.posY = this.initY;
                }
                this._wallMove(this.posX, this.posY);
            } else {
                if (this.posY >= -1000) {
                    this._wallMove(this.posX, this.posY);
                }
            }
        }
    },
});
